package SeedBank

/**
 * 
 * This class represents a seed with all its properties and constraints.
 *
 */
class Seed {

	//common name: , matches:/[A-Za-z][a-z]*( [A-Za-z][a-z]*)*/
	
	static constraints = {
		commonName(blank:false, size:1..100, matches:/[A-Za-z][a-z]*( [A-Za-z][a-z]*)*/)
		scientificName(blank: false, size:1..100, matches:/[A-Za-z][a-z]* [A-Za-z][a-z]*/)
		quantity(min:1)
		hardinessZone(min:1, max:12)
		specialRequirements(size:1..250)
		harvestingInformation(size:1..250)
		growingTips(size:1..250)
		startOfGrowingSeason()
		endOfGrowingSeason()
		price(min:0.0)
		}
	
	String commonName
	String scientificName
	int hardinessZone
	String specialRequirements
	String harvestingInformation
	int quantity
	BigDecimal price
	Date startOfGrowingSeason
	Date endOfGrowingSeason
	String growingTips
	Date dateCreated
	Date lastUpdated
	
	static belongsTo = [user:User]
	
	/**
	 * Overrides the toString method and specifies how a seed 
	 * should be represented in string
	 * 
	 * @return the string representation
	 */
	String toString(){
		return "${user.login}, ${commonName}, ${scientificName} (${quantity})"
	}

}
